﻿using ERP.Framework.Components.SortingHelper;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ERP.Framework.Components.SerializationHelper;
using System.Collections;

namespace ERP.Framework.Components.Testing.SerializationHelper.Test
{
    /// <summary>
    ///This is a test class for BinarySerializationManager 
    ///</summary>
    [TestClass()]
    public class BinarySerializationManagerTest
    {
        private string m_serializedText = string.Empty;
        private SerializingTestObject m_TestObject = new SerializingTestObject();

        /// <summary>
        ///A test for Serializing object
        ///</summary>
        [TestMethod()]
        public void BinarySerializeObjectTest()
        {
            m_serializedText = BinarySerializingManager.SerializeObject(m_TestObject);
            Assert.IsNotNull(m_serializedText);
            Assert.AreNotEqual(m_serializedText, string.Empty);
        }

        /// <summary>
        ///A test for Deserializing to object
        ///</summary>
        [TestMethod()]
        public void BinaryDeserializeObjectTest()
        {
            m_serializedText = BinarySerializingManager.SerializeObject(m_TestObject);
            SerializingTestObject serializedObj = ((SerializingTestObject)BinarySerializingManager.DeserializeObject<SerializingTestObject>(m_serializedText));
            
            Assert.IsNotNull(serializedObj);
            Assert.AreEqual(m_TestObject.ID , serializedObj.ID );
            Assert.AreEqual(m_TestObject.Name, serializedObj.Name);
            Assert.AreEqual(m_TestObject.RandomNumber, serializedObj.RandomNumber);
            Assert.AreEqual(m_TestObject.TestList.Count, serializedObj.TestList.Count);
        }
    }
}